import React from "react";
import { Table, Popconfirm, Button } from "antd";

export default function List({ list, onDelete }) {
  const columns = [
    {
      title: "编号",
      dataIndex: "id",
    },
    {
      title: "姓名",
      dataIndex: "username",
    },
    {
      title: "年龄",
      dataIndex: "userage",
    },
    {
      title: "操作",
      render: (text, record) => {
        return (
          <Popconfirm
            title="你确定要删除我吗?"
            onConfirm={() => {
              onDelete(record.id);
            }}
          >
            <Button>删除</Button>
          </Popconfirm>
        );
      },
    },
  ];
  return <Table dataSource={list} columns={columns} />;
}
